﻿<%@ Page Language="C#" AutoEventWireup="false" CodeFile="recDevolutionActionform.aspx.cs" Inherits="SIPO.Web.Forms.Administration.Catalog.recDevolutionActionform" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Devolution Action Form</title>
    <script src="<%= ResolveUrl("~/scripts/jquery.validate.min.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery.validate.wrapper.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery.inputmask.bundle.min.js") %>" type="text/javascript"></script>
</head>
<script type="text/javascript">

    $("#btnSave").button({ icons: { primary: "ui-icon-disk"} });
    $("#btnClose").button({ icons: { primary: "ui-icon-close"} });

    $('#btnClose').click(function () {
        parent.$('#dialog').dialog("close");
    });
 
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            // 1. prepare the validation rules and messages.
            var rules = {
                txtCode: "required",
                txtName: "required"
                
            };
            var messages = {
                txtCode: "Kode status pelimpahan wajib di isi!",
                txtName: "Nama status pelimpahan harus di isi!"

            };

            // 2. Initiate the validator
            var validator = new jQueryValidatorWrapper("form1", rules, messages);

            // 3. Set the click event to do the validation
            $("#btnSave").click(function () {
                if (!validator.validate())
                    return;

                var code = $('#txtCode').val();
                var name = $('#txtName').val();
                var id = $('#hfId').val();

                var objrecDevolutionAction = new Object();

                objrecDevolutionAction.DevolutionID = encodeURIComponent(id);
                objrecDevolutionAction.DevolutionCode = encodeURIComponent(code);
                objrecDevolutionAction.DevolutionName = encodeURIComponent(name);

                jsonData = JSON.stringify(objrecDevolutionAction);
                var handlerUrl = '<%= ResolveUrl("~/ajaxhandler/administration/catalog/recDevolutionActionhandler.ashx") %>';

                if (id == 0) {
                    CallAjax(handlerUrl, "?method=insert", jsonData);
                } else {
                    CallAjax(handlerUrl, "?method=update", jsonData);
                }

                parent.$('#dialog').dialog('close');

                setTimeout("parent.$('#table').trigger('reloadGrid');", 3000);

                return false;
            });
        });
    </script>
<body>
    <form id="form1" runat="server">
    <div>
    <table border="0">
        <tr>
            <td style="width: 50">
                Kode Status Pelimpahan
            </td>
            <td>
                :
            </td>
            <td>
                <asp:TextBox ID="txtCode" MaxLength="10" runat="server" Width="75"></asp:TextBox>&nbsp;<span
                    style="color: Red;">*</span>
            </td>
        </tr>
        <tr>
            <td>
                Nama Status Pelimpahan
            </td>
            <td>
                :
            </td>
            <td>
                <asp:TextBox ID="txtName" runat="server" Width="200" MaxLength="100"></asp:TextBox>&nbsp;<span
                    style="color: Red;">*</span>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                &nbsp;
            </td>
            <td>
                <div style="text-align: right; padding-top: 10px;">
                    <button id="btnSave" type="button">
                        Save</button>
                    <button id="btnClose" type="button">
                        Close</button>
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                &nbsp;
            </td>
            <td>
                <asp:HiddenField ID="hfId" runat="server" />
            </td>
        </tr>
    </table>
    </div>
    </form>
</body>
</html>
